home *** CD-ROM | disk | FTP | other *** search
/ Commodore 64 Scene Diskmags Assortment / Commodore_CEE_Vol._1_Issue_05_1995_Jack_Vander_White_Disk_2_of_3_Side_B.d64 / program bit 9 < prev   
Text File  |  2023-02-26  |  4KB  |  46 lines

  1. Accuracy of TI$ in C64 BASIC?
  2.  
  3. From: umcwikla@cc.umanitoba.ca (Tom Cwikla)
  4.  
  5. Antony Lord writes:
  6.  
  7. >I am currently using the TI$ variable in C64 BASIC to keep track of the time for some event work.
  8.  
  9. >Does anyone know how accurate this variable would be over a long period of time?
  10.  
  11. nb : Mains voltage here in Australian is 250VAC @ 50Hz and I don't know if the time base is based around the AC signal or an internal clocking chip.)
  12.  
  13. The time base for TI$ comes from the internal crystal, NOT from the "Time of Day" clocks that are kept in both CIA chips. (Why Commodore engineers decided to do this is a mystery to me.)
  14.  
  15. You can actually calculate how accurate TI$ is:
  16.  
  17. The time base is a crystal for 14.31818000 MHz (which is four times the NTSC color burst frequency, I believe PAL C64s have a different crystal in them) This then gets divided by 1.75 to give 8.181817143 MHz which is used as the DOT clock by the VIC chip. The VIC chip also divides this by 8 to give a 1.022727143 MHz system clock. The 16 bit timers (NOT the "Time of Day" clocks) in the CIA chips run off this frequency. The divider that the KERNAL uses for generating IRQ's is 17045. (If you wish to change this value, POKE it into locations 56324 and 56325 using standard LSB MSB format. The current value that's in the latch can not be read by doing a simple PEEK, as this is a running counter) So 1022727.143 cycles per second divided by 17045 gives an IRQ 60.00159242 times per second.  So this gives you 5184137.585 IRQs per day, when you really should be getting 5184000. So you have an extra 137.5850900 IRQs per day. This is an extra 2.293084833 seconds every day. So it will take about 26 days for the clock to drift off one whole minute. I'm afraid all of the above numbers apply only to NTSC machines.
  18.  
  19.  
  20. Of course all this is assuming that your crystal is 100% accurate. This is definately NOT the case with my C64. After running a BBS on it for several months I got tired of having to set the clock every week, so I got rid of all the references to TI$ and just used the CIA "Time of Day" clock which IS run off the 60 Hz mains. This is a lot more accurate in the long run (at least around here it is. I've heard stories from people in certain parts of Europe who's wall clocks run off the 50 Hz mains, and they need to be adjusted once every couple of days)
  21.  
  22. Sorry I couldn't get you the clock rates for PAL, but I have no idea what the crystal and divider settings are.
  23.  
  24. -------------------------
  25. Text to basic
  26.  
  27. From : Cspx
  28.  
  29. I cam accross this in the cbm main faq while back and thought you would all like to see this. I have tested it and it does indeed work and it faster than any other method I have ever seen. unfortunetly it only works for 64 mode. I am sure there is an equivalent version for the 128. Maby sometime in the future when I get some extra time I will try to figure it out. well ..anyways... here it is:
  30.  
  31. 13.5.  How do I transform a text file into a BASIC program?
  32.  
  33. Since Commodore BASIC stores its programs in "tokenized" format, one cannot simply load text files containing BASIC statements and run the file directly.  However, there is a solution.  In direct mode on a CBM 64, type in the following:
  34.  
  35. open1,8,2,"filename":poke781,1:poke812,73:sys 65478
  36.  
  37. This will read in each line of the text file and try to execute it (or store it if the line is preceded by a number).  When the last line of the program is entered, hit RUN/STOP-RESTORE, and type in the following:
  38.  
  39. close1:poke812,47:sys 65484
  40.  
  41. The file will now be loaded into memory.  Immediately save the file to disk as a BASIC program.
  42.  
  43. ------------------------
  44.  
  45.  
  46.